package com.gzx.plugin.tjzy.feign.call.receipt.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gzx.plugin.tjzy.feign.call.receipt.mapper.GzxCallReceiptFeignMapper;
import com.gzx.plugin.tjzy.feign.call.receipt.service.GzxCallReceiptFeignService;
import com.gzx.tjzy.feign.resp.call.receipt.GzxCallReceiptDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import vip.xiaonuo.common.tenant.TenantContext;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/4/25 10:58
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class GzxCallReceiptFeignServiceImpl implements GzxCallReceiptFeignService {

    private final GzxCallReceiptFeignMapper callReceiptFeignMapper;

    /**
     * 根据callId获取话单
     *
     * @param callIdList
     * @return
     */
    @Override
    @DS("tjzy-async")
    public List<GzxCallReceiptDto> getCallReceiptByCallIdList(List<String> callIdList) {
        return TenantContext.ignoreHandle(() -> callReceiptFeignMapper.selectList(Wrappers.<GzxCallReceiptDto>lambdaQuery()
                .in(GzxCallReceiptDto::getCallId, callIdList)));
    }

    /**
     * 话单补全质检审核状态
     *
     * @param callId
     * @param status
     */
    @Override
    @DS("tjzy-async")
    public void updateApproveStatus(String callId, Integer status) {
        TenantContext.ignoreHandle(() -> callReceiptFeignMapper.update(Wrappers.<GzxCallReceiptDto>lambdaUpdate()
                .set(GzxCallReceiptDto::getQcApproveStatus, status)
                .eq(GzxCallReceiptDto::getCallId, callId)));
    }
}
